package com.waghost.bridalgown.service.impl;

import com.waghost.bridalgown.dao.ReserveDao;
import com.waghost.bridalgown.dao.UserBgLikeDao;
import com.waghost.bridalgown.entity.Reserve;
import com.waghost.bridalgown.entity.Result;
import com.waghost.bridalgown.entity.UserBgLike;
import com.waghost.bridalgown.service.ReserveService;
import com.waghost.bridalgown.service.UserBgLikeService;
import com.waghost.bridalgown.utils.UserUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.UUID;

@AllArgsConstructor
@Service
public class IReserveService implements ReserveService {

    private ReserveDao reserveDao;


    @Override
    public Result list() {
        return Result.success(reserveDao.listMapper());
    }

    @Override
    public Result getOrder(Integer id) {
        return Result.success(reserveDao.getOrder(id));
    }

    @Override
    public Result getId(Integer id) {
        return Result.success(reserveDao.userOrder(id));
    }

    @Override
    public Result getStatus(Integer status,Integer userId) {
        return Result.success(reserveDao.getStatus(status,userId));
    }

    @Override
    public Result add(Reserve reserve) {
        reserve.setCreateTime(new Date());
        reserve.setOrderId(UUID.randomUUID().toString());
        return Result.toAjax(reserveDao.insert(reserve), "添加成功", "添加错误");
    }

    @Override
    public Result update(Reserve reserve) {
        reserve.setUpdateTime(new Date());
        return Result.toAjax(reserveDao.updateById(reserve), "修改成功", "修改错误");
    }

    @Override
    public Result delete(Integer id) {
        return Result.toAjax(reserveDao.deleteById(id), "删除成功", "删除错误");
    }

}
